import { defineStore } from 'pinia';
import { getInfo } from '@/api/auth.js'

export const useUserStore = defineStore('user', {
  state: () => {
    return {
      // 所有这些属性都将自动推断出它们的类型
      name: '',
      avatar: '',
      sex: '',
      sign: ''
    }
  },
  actions: {
    async getUserInfo(name,password) {
      const res = await getInfo({ name, password});
      if (res.code === 1) {
        this.name = res.data.name;
        this.avatar = res.data.avatar;
        this.sex = res.data.sex;
        this.sign = res.data.sign;
      }
    },
  }

}
);